package com.sky.context;

public class BaseContext {

    // 1. 定义一个静态的ThreadLocal变量，用于存储Long类型的线程本地数据
    public static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    // 2. 设置当前线程的ID
    public static void setCurrentId(Long id) {
        threadLocal.set(id);
    }

    // 3. 获取当前线程的ID
    public static Long getCurrentId() {
        return threadLocal.get();
    }

    // 4. 清除当前线程的ID（防止内存泄漏）
    public static void removeCurrentId() {
        threadLocal.remove();
    }

}
